<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"  %>
<script type="text/javascript">
$('#createProjectY').validate({
		submitHandler : function(form) {
			$.post('./project/createProject.action', $('#createProjectY')
					.serialize(), function(respuestaHTML) {
				$('#content').html(respuestaHTML);
			});
		}
	});


$('#NewProjectStatusDiv').hide();
$.unblockUI();


$('#newProjectStatus').validate(
		{
			submitHandler : function(form) {
				$.post('./project/newProjectStatus.action', $(
						'#newProjectStatus').serialize(), function(
						respuestaHTML) {
					$('#content').html(respuestaHTML);
				});
			}
		});




$('#userPersonName').autocomplete({
	source : "./datosjson/searchUserPersons",
	minLength : 2,
	select : function(event, ui) {
		$('#idUserPerson').val(ui.item.id);
		$('#userPersonName').css('background-color', '#787878');
		$('#userPersonName').attr('readonly', 'true');
	}
});

function limpiarBusqueda() {
	$('#idUserPerson').val('');
	$('#userPersonName').val('');
	$('#userPersonName').removeAttr("readonly");
	$('#userPersonName').css('background-color', 'white');
}

function showNewProjectStatus() {
	$('#NewProjectStatusDiv').show();
}
$('#startDate').datepicker();
$('#finishDate').datepicker();
</script>
<h4>
	New Project:
</h4>
<br>
<s:form id="createProjectY" action="test.action">
	<s:hidden name="project.id" />
	<s:hidden name="idUserPerson" id="idUserPerson"/>
	<s:textfield name="project.name" label ="Name" cssClass="required" />
	<s:textfield name="project.hours" label ="Hours" cssClass="required" />
	<s:textfield name="userPersonName" label ="Leader" id="userPersonName"/>
	<tr><td><s:a cssClass="btn btn-mini" href="#" onclick="limpiarBusqueda()">Change Leader</s:a></td><td></td></tr>
    <s:select name="project.projectStatus.id" list="projectsStatus" listValue="name" listKey="id" label="Project Status"></s:select>
   	<tr><td><a class="btn btn-mini" href="#" onclick="showNewProjectStatus()">New Project Status</a></td><td></td></tr>
	<s:textfield name="project.period.startDate" label ="Start Date" id="startDate"/>
	<s:textfield name="project.period.endDate" label ="End Date" id="finishDate"/>
	<s:submit cssClass="btn btn-success" value="Save" />
</s:form>

<div id=NewProjectStatusDiv>
<s:form action="./project/newProjectStatus.action" id="newProjectStatus" >
	<s:hidden name="projectStatus.id" />
	<s:textfield name="projectStatus.name" label = "Name" cssClass="required" />
	<s:submit id="botSaveStatus" value="Save" />
</s:form>
</div>